﻿using GLWrap.MathExt;
using Tao.OpenGl;
using Sharp3D.Math.Core;

namespace GLWrap.SceneObjects
{
    public class Sphere: SceneObject
    {
        private GluQuadricObject _gluQuadricObject;

        public float Radius { get; set; }
        public Vector3F Position { get; set; }

        public Sphere()
        {
            Radius = 0.1f;
        }

        protected override void InternalDraw(GlSceneManager sceneManager)
        {
            Gl.glTranslatef(Position.X,Position.Y,Position.Z);
            Glu.gluSphere(_gluQuadricObject.Quadric,Radius,25,25);    
        }

        protected override void InternalAttachToScene(GlSceneManager sceneManager)
        {
            _gluQuadricObject = new GluQuadricObject();
        }

        protected override void InternalDetachFromScene(GlSceneManager sceneManager)
        {
            _gluQuadricObject.Dispose();
        }
    }
}
